﻿using System;
using System.Linq.Expressions;
using Iot.AlarmDispose.Database.Entities;

namespace Iot.AlarmDispose.Database;

/// <summary>
///     将警报历史记录写入数据库的接口
/// </summary>
public interface IHistoricalRecord<TAlertClassify, TAlertsHistory>
    where TAlertClassify : class, IAlertClassify
    where TAlertsHistory : class, IAlertsHistory<TAlertClassify>
{
    /// <summary>
    ///     将警报历史记录写入数据库
    /// </summary>
    /// <param name="alerts"></param>
    /// <returns></returns>
    bool Add(TAlertsHistory alerts);

    /// <summary>
    ///     更新警报结束时间记录
    /// </summary>
    /// <param name="id"></param>
    /// <param name="endTime"></param>
    /// <returns></returns>
    bool Update(long id, DateTimeOffset endTime);

    /// <summary>
    ///     删除警报历史记录
    /// </summary>
    /// <param name="predicate"></param>
    /// <returns></returns>
    int Delete(Expression<Func<TAlertsHistory, bool>> predicate);
}